asm
  ld sp,$87FF
  end asm

#include "./library/smsrnd.bas"

dim eee as uinteger at $8010
dim seed as uinteger at $8012
dim ee2 as uinteger at $8014
dim ee3 as uinteger at $8016
dim ee4 as uinteger at $8018
dim ee5 as uinteger at $801A
dim ex0 as uinteger at $8020
dim ey0 as uinteger at $8022
dim ej0 as uinteger at $8024
dim ej1 as uinteger at $8026

seed=0

sub chacknpopputchar(txpos as uinteger,typos as uinteger,tchr as ubyte):
  poke $9000+txpos+(typos*32),tchr
  end sub

sub chacknpopputsprite(tlayer as uinteger,txpos as ubyte,typos as ubyte,tid as ubyte,tclut as ubyte):
  poke $9840+(tlayer*4),typos bxor $FF
  poke $9841+(tlayer*4),tid
  poke $9842+(tlayer*4),tclut
  poke $9843+(tlayer*4),txpos
  end sub


'-------------------------------------------------------------------------------

for ee2=0 to 31
  for ee3=0 to 31
    chacknpopputchar(ee3,ee2,code("."))
    next:next

for ee2=0 to 15
  for ee3=0 to 15
    chacknpopputchar(ee3+14,ee2+12,ee3+(ee2*16))
    next:next

for eee=$9800 to $983F '- attr  64 bytes - ?????????????
  for ee2=1 to 1000:next
  seed=smsrnd(seed)
  poke eee,seed
  next

for eee=$9840 to $98FF '- sprites - 192 bytes
  poke eee,eee
  next

ex0=40:ey0=40
eee=0

do
  ej0=peek($8809) bxor $FF
  ej1=peek($880B) bxor $FF
  chacknpopputchar(8,25,48+(ej0 mod 10))
  chacknpopputchar(7,25,48+((int(ej0/10)) mod 10))
  chacknpopputchar(6,25,48+((int(ej0/100)) mod 10))
  chacknpopputchar(8,26,48+(ej1 mod 10))
  chacknpopputchar(7,26,48+((int(ej1/10)) mod 10))
  chacknpopputchar(6,26,48+((int(ej1/100)) mod 10))

  for ee2=0 to 5
    for ee3=0 to 7
      chacknpopputsprite(ee3+(ee2*8),ex0+(ee3*16),ey0+(ee2*16),eee band 15,eee band 15)
      next:next

  ex0=ex0-((ej0 band 1)/1)+((ej0 band 2)/2)
  ey0=ey0+((ej0 band 4)/4)-((ej0 band 8)/8)

  eee=eee+1
  for ee2=1 to 500:next
  loop

do:loop


